package com.api.oa.mapper;

import com.api.oa.model.entity.YQFeedBack;
import com.api.oa.model.vo.OaNoticeVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface YQFeedBackMapper {

    @Insert("insert into  yq_feedback  (" +
            "feedbackId," +
            "userId," +
            "feedbackPhone," +
            "feedbackContent," +
            "createdAt" +
            ") " +
            "values " +
            "(" +
            "#{entity.feedbackId}," +
            "#{entity.userId}," +
            "#{entity.feedbackPhone}," +
            "#{entity.feedbackContent}," +
            "#{entity.createdAt}" +
            ")")
    @Options(useGeneratedKeys = true, keyProperty = "feedbackId", keyColumn = "id")
    Integer insert(@Param("entity") YQFeedBack entity);


    @Update("update  yq_feedback  set " +
            "feedbackId = #{entity.feedbackId}," +
            "userId = #{entity.userId}," +
            "feedbackPhone = #{entity.feedbackPhone}," +
            "feedbackContent = #{entity.feedbackContent}," +
            "createdAt = #{entity.createdAt}" +
            " where messageId = #{entity.classifyId}")
    Integer update(@Param("entity") YQFeedBack entity);


    @Delete("delete from yq_feedback where feedbackId=#{id}")
    void delete(@Param("id") Long id);


    @Select("<script> select * from  yq_feedback where 1=1 <if test='keyWord!=null'> and feedbackContent like concat('%',#{keyWord},'%') </if></script>")
    List<YQFeedBack> list(@Param("keyWord") String keyWord);


    @Select("select * from  yq_feedback  where feedbackId = #{id} limit 1")
    YQFeedBack findOne(@Param("id") Long id);

}

